home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-03-06 | 1.6 KB | 43 lines | [TEXT/GEOL] |
- Item 0925155 12-Dec-90 23:30PST
-
- From: MADA.SYSOP MacApp Dev Assoc, Don Sawtelle,IVC
-
- To: MACAPP.TECH$ MacApp Technical
-
- ------------------------------------------------------------------------------
-
- Sub: Re: global Reference, ViewEdi
-
- [From PaulLX on America Online at 90-12-12 21:26:09 EST]
-
- Thanks! I'll give that a try.
-
- I just ran into another problem that I need some clarification on. I am
- writing a program that does material and energy balances on combustors. One
- class I created is called TGasStream, which is essentially a gas stream. I
- tried to create a global Function that would add two streams together and
- return a third stream, with the interface:
-
- FUNCTION AddStreams(stream1,stream2:TGasStream):TGasStream;
- VAR
- aGasStream : TGasStream;
- Begin
- { call methods from aGasStream without creating it first }
- End;
-
- I then reference methods of aGasStream inside of the Function, but never call
- New(aGasStream). I get errors related to FAILNONOBJECT. I assume that it is
- because aGasStream is not allocated. If I create a New(aGasStream) within this
- function, do I need to Free it before I exit the function? It seems to me that
- if I do the following...
-
- New(anotherGasStream);
- FailNil(anotherGasStream);
- anotherGasStream.IGasStream;
- anotherGasStream := AddStreams(stream1,stream2);
-
- It appears that I would have a memory leak generated if I don't Free the local
- variable within the Function. Is that true? I'm not sure, because I can't
- find an example that actually does something like this.
-
-